﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using EasierRdp.Models;
using EasierRdp.Util;

namespace EasierRdp
{
    partial class SettingDialog : Form
    {
        public RdpSetting Setting { get; set; }

        public SettingDialog()
        {
            InitializeComponent();
        }

        private void ButtonOk_Click(object sender, EventArgs e)
        {
            if (Setting == null)
            {
                Setting = new RdpSetting();
            }
            Setting.Width = TextWidth.Text.ParseNullableInt();
            Setting.Height = TextHeight.Text.ParseNullableInt();
            Setting.FullScreen = CheckboxFullScreen.Checked;
            Setting.Name = TextName.Text;
            RdpContext.AddSetting(Setting);
            this.DialogResult = DialogResult.OK;
            this.Hide();
            EasierRdpEvents.RebindTreeView();
        }

        private void SettingDialog_Load(object sender, EventArgs e)
        {
            if (Setting != null)
            {
                TextName.Text = Setting.Name;
                TextHeight.Text = Setting.Height.ToString();
                TextWidth.Text = Setting.Width.ToString();
                CheckboxFullScreen.Checked = Setting.FullScreen;
            }
        }

        private void ButtonCancel_Click(object sender, EventArgs e)
        {
            this.Hide();
        }
    }
}
